#!/usr/bin/perl
# Version 0.2.1

$testcase = "use";

# 1 = PASS
# 2 = FAIL
# 3 = INCONCLUSIVE
$verdict = 3;

$dumpfile = "$testcase.dump";
$logfile = "$testcase.log";

if ($#ARGV ne 1) {
        print("Usage: $testcase.pl dumpfile log_file");
        exit 1;
}

$logfile = $ARGV[1];
$dumpfile = $ARGV[0];

#------------------------------------------------------------------------------


$success = 1;
$state = 0;

open(DUMPFILE, $dumpfile) or $success = 0;

if ($success eq 1) {
	while(<DUMPFILE>) {
		
		if(/0\.0\.0\.21(.*) > 0\.0\.0\.17.10: (.*) win(.*)/) {

			$state = $state | 1;
		} elsif (/0\.0\.0\.17\.10 > 0\.0\.0\.21(.*): (.*) win(.*)/) {
			$state = $state | 2;
		}		
	}
	
	if($state eq 3) { 
		$verdict = 1;
	} else {
		$verdict = 2;
	}
	
	close(DUMPFILE);
}	

if ($verdict eq 1) {
	print("Packets travel correctly. Test PASSED.\n");
} elsif ($verdict eq 2) {
	print("Packets do not travel correctly ($state). Test FAILED.\n");
} else {
	print("Cannot evaluate Results. Test INCONCLUSIVE.\n");
}

#------------------------------------------------------------------------------
print("### VERDICT for $testcase: ");

if ($verdict eq 1) { 
        print("PASS"); 
} elsif ($verdict eq 2) {
        print("FAIL");
} else {
        print("INCONCLUSIVE");
}

print(" ###\n");
